Use :ident
matcher instead of :ty
matcher
#17
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a
:ty
matcher is used in amacro_rules!
macro, the capturedargument can no longer be used to match a literal in a new
macro_rules!
invocation. For example, the following code:produces the following error:
That is, once
my_val
is captured as a:ty
, it will not match amy_val
literalin the
inner!
invocation.Due to a bug in rustc, code like this was accepted by the compiler
when a proc-macro attribute was applied to the macro invocation.
This affects
fourier-algorithms
due to the following code:The
avx_vector!
macro is expecting eitherf32
orf64
as an ordinary token. However, the
$type
metavariable uses a:ty
matcher, which will prevent it from matching againstf32
or
f64
(even though the captured type is alwaysf32
orf64
).Due to the
target_cfg
attribute proc-macro, this code was incorrectlyallowed to compile. When the underlying bug in rustc is fixed
in rust-lang/rust#73084,
fourier-algorithms
will stop compiling.
This commit changes two
:ty
matchers to:ident
matchers, which canbe used as arguments to a
macro_rules!
macro expecting a plainf32
or
f64
token. This will still compile on existing compile versions,and will allow
fourier-algorithms
to continue to compile oncerust-lang/rust#73084 is merged into rustc.